package com.whnk.web.controller.evo;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.whnk.common.annotation.Log;
import com.whnk.common.enums.BusinessType;
import com.whnk.evo.domain.SealInfo;
import com.whnk.evo.service.ISealInfoService;
import com.whnk.framework.web.base.BaseController;
import com.whnk.framework.web.page.TableDataInfo;
import com.whnk.common.base.AjaxResult;

/**
 * 公章 信息操作处理
 * 
 * @author whwhnk
 * @date 2019-09-06
 */
@Controller
@RequestMapping("/evo/sealInfo")
public class SealInfoController extends BaseController
{
    private String prefix = "evo/sealInfo";
	
	@Autowired
	private ISealInfoService sealInfoService;
	
	@RequiresPermissions("evo:sealInfo:view")
	@GetMapping()
	public String sealInfo()
	{
	    return prefix + "/sealInfo";
	}
	
	/**
	 * 查询公章列表
	 */
	@RequiresPermissions("evo:sealInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(SealInfo sealInfo)
	{
		startPage();
        List<SealInfo> list = sealInfoService.selectSealInfoList(sealInfo);
		return getDataTable(list);
	}
	
	/**
	 * 新增公章
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存公章
	 */
	@RequiresPermissions("evo:sealInfo:add")
	@Log(title = "公章", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(SealInfo sealInfo)
	{		
		return toAjax(sealInfoService.insertSealInfo(sealInfo));
	}

	/**
	 * 修改公章
	 */
	@GetMapping("/edit/{sealId}")
	public String edit(@PathVariable("sealId") Integer sealId, ModelMap mmap)
	{
		SealInfo sealInfo = sealInfoService.selectSealInfoById(sealId);
		mmap.put("sealInfo", sealInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存公章
	 */
	@RequiresPermissions("evo:sealInfo:edit")
	@Log(title = "公章", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(SealInfo sealInfo)
	{		
		return toAjax(sealInfoService.updateSealInfo(sealInfo));
	}
	
	/**
	 * 删除公章
	 */
	@RequiresPermissions("evo:sealInfo:remove")
	@Log(title = "公章", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(sealInfoService.deleteSealInfoByIds(ids));
	}
	
}
